package com.ayg.service;

import com.ayg.mapper.PersonalMapper;
import com.ayg.pojo.Personal;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonalServiceImpl implements PersonalService{

    @Autowired
    private PersonalMapper personalMapper;

    /**
     * 添加信息
     * @param personal
     */
    @Override
    public void SavePersonalInfo(Personal personal) {
        personal.setStatus(true);
        personalMapper.insert(personal);
    }

    /**
     * 查看信息
     * @return
     */
    @Override
    public List<Personal> getTabPersonal() {
        List<Personal> personalList = personalMapper.selectList(null);
        return personalList;
    }

    @Override
    public void deletePersonalById(Integer id) {
        personalMapper.deleteById(id);
    }

    @Override
    public Personal getPersonalById(String personalName) {
        QueryWrapper<Personal> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("personal_name",personalName);
        return personalMapper.selectOne(queryWrapper);
    }

    @Override
    public void updateInfo(Personal personal) {

        personalMapper.updateById(personal);
    }


}
